(function () {

	//获取当前(备件、备泵、维修)合同已关联项目合同数据 服务器分页
    var contractRelevanceData = {};
    contractRelevanceData.contractId=jQuery('#contractId').val();
    var serverRelevanceTable;
    jQuery(document).ready(function () {
    	serverRelevanceTable = jQuery('#resultRelevanceTable').DataTable({
            "serverSide": true,
            "ordering": false,
            "iDisplayLength": 5,
            "ajax": {
                "dataType": "json",
                "type": "get",
                "cache": false,
                "url":window.rootPath+ '/ui/contract/getRelevanceContract',
                "data": function (d) {
                    return $.extend({}, d, contractRelevanceData);
                }
            },
            columns: [
                {
                	data: null
                },
                {
                    data: 'supplierCode'
                },
                {
                    data: 'projectName'
                },
                {
                    data: 'signedDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                }
                ],
            "drawCallback": function (oSettings) {
                var k = 0;
                var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                    $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                    k++;
                }
            }
        });
    	
    	$('#myTabs a[href="#tab1"]').on('shown.bs.tab', function(e){
    		contractRelevanceData.contractId=jQuery('#contractId').val();
    		serverRelevanceTable.draw(true);
    	});
    	
    	
    });
})();